package com.business.base;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.system.database.DS;

@Service("baseService")
@Transactional
public class BaseService {

	
	@Autowired
	private BaseDao baseDao;
	
	public void insertBusiness(Map<String, Object> item)
	{
		baseDao.save("base.insert", item);
	}
	public void updateBusiness(Map<String, Object> item)
	{
		baseDao.update("base.update", item);
	}
	public void deleteBusiness(Map<String, Object> item)
	{
		baseDao.delete("base.delete", item);
	}
	public Pager<Map<String, Object>> selectBusiness(Map<String, Object> item,int pageIndex, int pageSize)
	{
		Pager<Map<String, Object>> result= baseDao.selectListByPage(pageIndex,pageSize,"base.select", item);
		
		for (int i = 0; i < result.getList().size(); i++) {
			Map<String, Object> item2 = result.getList().get(i);
			item2.put("IndexNumber", (pageIndex - 1) * pageSize + i + 1);
		}
		
		return result;
	}
	public List<Map<String, Object>> selectBusiness(Map<String, Object> item)
	{
		List<Map<String, Object>> result= baseDao.selectList("base.select", item);
		
		return result;
	}
	
	public void processOrderBusiness(Map<String, Object> item1,Map<String, Object> item2)
	{
		baseDao.update("base.update", item1);
		baseDao.update("base.update", item2);
	}
	
	@DS("formDb")
	public void processOrderForm(Map<String, Object> item1,Map<String, Object> item2)
	{
		baseDao.update("base.update", item1);
		baseDao.update("base.update", item2);
	}
	
	@DS("frameDb")
	public void processOrderFrame(Map<String, Object> item1,Map<String, Object> item2)
	{
		baseDao.update("base.update", item1);
		baseDao.update("base.update", item2);
	}
	
}
 